using Godot;
using System;

public partial class Cell : Control
{
	public delegate void OnButtonDown(Cell cell);
	public int index = 0;
	public int state = 0;
	public Button button;
	public TextureRect textureRect_state_0, textureRect_state_1;
	public MainMenu mainMenu;

	public OnButtonDown ButtonDown;
	public override void _Ready()
	{
		mainMenu = GetParent<MainMenu>();
		textureRect_state_0 = GetNode<TextureRect>("TextureRect_State_0");
		textureRect_state_1 = GetNode<TextureRect>("TextureRect_State_1");
		button = GetNode<Button>("Button");
		button.ButtonDown += () =>
		{
			if (ButtonDown != null) ButtonDown(this);
		};
	}
	public override void _Process(double delta)
	{
		if(mainMenu.server!=null&&mainMenu.server.inGame==null)state=0;
		if (state == 0)
		{
			textureRect_state_0.Visible = false;
			textureRect_state_1.Visible = false;
		}
		if (state == 1)
		{
			textureRect_state_0.Visible = true;
			textureRect_state_1.Visible = false;
		}
		if (state == 2)
		{
			textureRect_state_0.Visible = false;
			textureRect_state_1.Visible = true;
		}
	}
}
